﻿<ResourceDictionary
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="clr-namespace:Coding4Fun.Toolkit.Controls">
	
	<Style TargetType="local:RoundToggleButton">
		<Setter Property="BorderBrush" Value="{StaticResource DefaultForegroundBrush}" />
		<Setter Property="Foreground" Value="{StaticResource DefaultForegroundBrush}" />
		<Setter Property="FontFamily" Value="{StaticResource FontFamilySegoeSemiBold}" />
		<Setter Property="CheckedBrush" Value="{StaticResource DefaultAccentBrush}" />
		<Setter Property="FontSize" Value="{StaticResource DefaultFontSizeExtraSmall}" />
		<Setter Property="ButtonWidth" Value="{StaticResource DefaultAppButtonSize}"/>
		<Setter Property="ButtonHeight" Value="{StaticResource DefaultAppButtonSize}" />
		
		<Setter Property="Template">
			<Setter.Value>
				<ControlTemplate TargetType="local:RoundToggleButton">
					<Grid>
						<VisualStateManager.VisualStateGroups>
							<VisualStateGroup x:Name="CheckStates">
								<VisualState x:Name="Checked">
									<Storyboard>
										<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Fill" Storyboard.TargetName="ButtonBackground">
											<DiscreteObjectKeyFrame KeyTime="0" Value="{Binding CheckedBrush, RelativeSource={RelativeSource TemplatedParent}}" />
										</ObjectAnimationUsingKeyFrames>
										<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Fill" Storyboard.TargetName="DisabledButtonBackground">
											<DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource DefaultDisabledBrush}"/>
										</ObjectAnimationUsingKeyFrames>
										<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="StrokeThickness" Storyboard.TargetName="DisabledButtonRing">
											<DiscreteObjectKeyFrame KeyTime="0" Value="0"/>
										</ObjectAnimationUsingKeyFrames>
										<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Foreground" Storyboard.TargetName="DisabledContent">
											<DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource DefaultContrastDisabledBrush}"/>
										</ObjectAnimationUsingKeyFrames>
									</Storyboard>
								</VisualState>
								<VisualState x:Name="Unchecked" />
								<VisualState x:Name="Indeterminate"/>
							</VisualStateGroup>
							<VisualStateGroup x:Name="CommonStates">
								<VisualState x:Name="Normal"/>
								<VisualState x:Name="Disabled">
									<Storyboard>
										<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Visibility" Storyboard.TargetName="EnabledBackground">
											<DiscreteObjectKeyFrame KeyTime="0">
												<DiscreteObjectKeyFrame.Value>
													<Visibility>Collapsed</Visibility>
												</DiscreteObjectKeyFrame.Value>
											</DiscreteObjectKeyFrame>
										</ObjectAnimationUsingKeyFrames>
										<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Visibility" Storyboard.TargetName="DisabledBackground">
											<DiscreteObjectKeyFrame KeyTime="0">
												<DiscreteObjectKeyFrame.Value>
													<Visibility>Visible</Visibility>
												</DiscreteObjectKeyFrame.Value>
											</DiscreteObjectKeyFrame>
										</ObjectAnimationUsingKeyFrames>
									</Storyboard>
								</VisualState>
							</VisualStateGroup>
						</VisualStateManager.VisualStateGroups>
						
						<Border 
							Name="EnabledBackground" 
							Height="{TemplateBinding Height}"
							Width="{TemplateBinding Width}"
							Padding="{TemplateBinding Padding}" 
							BorderThickness="0" 
							BorderBrush="Transparent" 
							Background="Transparent">
							<StackPanel Orientation="{TemplateBinding Orientation}">
								
								<Grid 
									Width="{TemplateBinding ButtonWidth}" 
									Height="{TemplateBinding ButtonHeight}" 
									Margin="0,-10, 0, 0">

									<Ellipse
										x:Name="ButtonBackground"
										Stroke="Transparent" 
										Fill="{TemplateBinding Background}" 
										Margin="10" />

									<Grid Name="ContentHost">
										<ContentControl 
											Name="EnabledContent"
											Foreground="{TemplateBinding Foreground}"
											HorizontalContentAlignment="Center" 
											VerticalContentAlignment="Center">
											<Grid Name="EnabledHolder">
												<ContentControl
													Name="ContentBody" 
													Content="{TemplateBinding Content}" />
											</Grid>
										</ContentControl>
									</Grid>
									
									<Ellipse
										x:Name="ButtonRing"
										Stroke="{TemplateBinding BorderBrush}" 
										StrokeThickness="3" 
										Fill="Transparent" 
										Margin="10" />
								</Grid>

								<ContentControl 
									Name="ContentTitle"
									Margin="0, -5, 0 , 0"
									Content="{TemplateBinding Label}" 
									Foreground="{TemplateBinding Foreground}" 
									HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}" 
									VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"
									Style="{StaticResource AppBarText}"/>

							</StackPanel>
						</Border>
						<Border 
							Name="DisabledBackground" 
							Height="{TemplateBinding Height}"
							Width="{TemplateBinding Width}"
							Padding="{TemplateBinding Padding}" 
							BorderThickness="0" 
							BorderBrush="Transparent" 
							Background="Transparent" 
							Visibility="Collapsed">
							<StackPanel Orientation="{TemplateBinding Orientation}">
								<Grid 
									Width="{TemplateBinding ButtonWidth}" 
									Height="{TemplateBinding ButtonHeight}" 
									Margin="0,-10, 0, 0">
									<Ellipse
											x:Name="DisabledButtonBackground"
											Stroke="Transparent" 
											Margin="10" />

									<Grid Name="DisabledContentHost">
										<ContentControl 
											Name="DisabledContent" 
											Foreground="{StaticResource DefaultDisabledBrush}"
											HorizontalContentAlignment="Center" 
											VerticalContentAlignment="Center">
											<Grid Name="DisabledHolder" />
										</ContentControl>
									</Grid>

									<Ellipse
										x:Name="DisabledButtonRing"
										Stroke="{StaticResource DefaultDisabledBrush}" 
										StrokeThickness="3"
										Fill="Transparent"
										Margin="10" />
								</Grid>
								
								<ContentControl 
									Content="{TemplateBinding Label}" 
									Foreground="{StaticResource DefaultDisabledBrush}" 
									HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}" 
									VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"
									Margin="{Binding Margin, ElementName=ContentTitle}"
									Style="{StaticResource AppBarText}" />
								
							</StackPanel>
						</Border>
					</Grid>
				</ControlTemplate>
			</Setter.Value>
		</Setter>
	</Style>
</ResourceDictionary>